﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using System.Web.Services;
using DDSC.OracleADO;
using System.Collections;
using System.Text;
using System.Data;

public partial class krj_tracking_mistakenly_discharged : BasePermissionPage
{
    //搜尋SQL-發送資料
    [WebMethod]
    public static Object GetCorrection(string CORRECT_NO, string sType, PageInfo p_PageInfo)
    {
        Object results = new Object();
        try
        {
            dbAccess m_dba = new dbAccess();
            StringBuilder m_sb = new StringBuilder();
            ArrayList m_arrParam = new ArrayList();

            m_sb.Append(" select SA2114 scan_date,SA2115 scan_time ,SA2102 || ' ' || B.DEPT_NAME scan_dept ,SA2113 scan_count ,SA2111 || ' ' || C.USER_NAME CHECK_USER_ID ");
            //m_sb.Append(" ,F63153 LINE_TYPE , KD1102 LINE_NAME  ");
            m_sb.Append(" from as400_SAF21 A left join MIS_DEPT_AP B on A.SA2102 = B.DEPT_ID "); 
            m_sb.Append(" left join MIS_USER_AP C on A.SA2111 = C.USER_ID ");
            //m_sb.Append(" left join AS400_KDF11 D on A.F63153 = D.KD1101  ");

            m_sb.Append(" where SA2101 =:CORRECT_NO ");
            m_arrParam.Add(m_dba.GetOracleParam(":CORRECT_NO", CORRECT_NO));

            results = ADOGridHandler(m_sb, m_arrParam, p_PageInfo);
        }
        catch (Exception ex)
        {
            results = ex.Message;
        }
        return (results);

    }
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {

            if (!Page.IsPostBack)
            {
                string mode = (string)Request["mode"];
                if (PreviousPage != null)
                {
                    krj_tracking_detail previous = PreviousPage as krj_tracking_detail;
                    mode = previous.Mode;
                    //從前一頁帶入KEY資料
                    if (mode != "Insert")
                    {
                        lblCORRECTION_NO.Text = krj_tracking_detail.GridKey["CORRECTION_NO"].ToString();
                        lblSHIPPING_NO.Text = krj_tracking_detail.GridKey["DETAIL_NO"].ToString() + krj_tracking_detail.GridKey["ITEM_NO"].ToString();
                        lblRECEIVED_DEPT.Text = krj_tracking_detail.GridKey["RECEIVED_DEPT"].ToString();
  
                    }
                    //執行搜尋功能
                    ClientScript.RegisterClientScriptBlock(this.GetType(), "btnSearch_Click", "<script language='javascript'>$(document).ready(function () {btnSearch_Click(''); }) </script>");
                }


            }
            
        }
        catch (Exception ex)
        {
            //Response.Write(e.Message);
            lbl_message.Text = ex.Message;

        }
    }
}